/*
 * @Author: soso
 * @Date: 2022-01-21 15:56:10
 * @LastEditTime: 2022-02-17 15:45:08
 * @LastEditors: Please set LastEditors
 * @Description: 系统内命令定义
 * @FilePath: /go-mesh-sync/core/command/mesh.go
 */

package scmd

import (
	"sync"

	"gitee.com/kimsoso/go-utils/sofile"
)

const (
	SAME   = 2  // 文件相同
	ADD    = 1  // 文件新增
	UPDATE = 0  // 文件更新
	DELETE = -1 // 文件已删除
	RENAME = 3  // 文件已删除

	IsFile uint8 = 0
	IsDir  uint8 = 1
)

// 下载文件结构体
type Ufile struct {
	Path     string `yaml:"pt"`
	FileType uint8  `yaml:"ft"`
	FileMd5  string `yaml:"md5"`
	FileSize int64  `yaml:"sz"`
}

type MCommand struct {
	Ck         int    `yaml:"ck"`
	Cmd        int    `yaml:"cd"`
	Path       string `yaml:"pt"`
	ToPath     string `yaml:"tpt"`
	File       *Cfile `yaml:"f"`
	CreateTime int64  `yaml:"cT"`
	DoneTime   int64  `yaml:"dT"`
	Done       bool   `yaml:"d"`
}

type Cfile struct {
	FileMd5         string `yaml:"md5"`
	FilePath        string `yaml:"fp"`
	FileName        string `yaml:"fn"`
	FileSize        int64  `yaml:"fs"`
	BlockSize       int64  `yaml:"bs"`
	FileMask        string `yaml:"fm"`
	CreateTime      string `yaml:"ct"`
	CreateTimeStamp int64  `yaml:"cts"`
	Expiration      int64  `yaml:"exp"`
	Checked         bool   `yaml:"chd"`
}

type MCommands struct {
	sync.RWMutex
	path   string `yaml:"p"`
	curseq int    `yaml:"cs"`
	blocks *sofile.Blockfile
	// files  map[string]*Cfile
	cmds map[string]*MCommand
}
